var personal = {
    init: function () {
        var that = this;
        that.bind();
    },
    bind: function () {
        util.carousel({
            items: '.messages .banner ul.list li',
            indicators: '.messages .banner .carousel ol.indicators li a',
            delay: 6000
        });
    }
};
// 常见问题切换
var problems = {
    speed: {
        init:0,
        ani:50
    },
    init: function () {
        this.stopPropagation();
        this.registerEvent();
        this.setOpen();
    },
    stopPropagation: function () {
        var $a = $('.collapse .collapse-item a');
        $a.on('click', function (event) {
            event.stopPropagation();
        })
    },
    registerEvent: function () {
        var that = this,
            $item = $('.collapse .collapse-item');
        $item.each(function () {
            $(this).on('click', function () {
                problems.speed.init = problems.speed.ani;
                if ($(this).hasClass('active')) {
                    $(this).removeClass('active');
                    that.setOpen();
                } else {
                    that.removeActive();
                    $(this).addClass('active');
                    that.setOpen();
                }
            })
        })
    },
    removeActive: function () {
        var $item = $('.collapse .collapse-item');
        $item.each(function () {
            $(this).removeClass('active');
        })
    },
    setOpen: function () {
        var $speed = problems.speed.init;
        var $item = $('.collapse .collapse-item');
        $item.each(function () {
            var $item_bd = $(this).children('.collapse-bd');
            if ($(this).hasClass('active')) {
                $item_bd.slideDown($speed);
            } else {
                $item_bd.slideUp($speed);
            }
        })
    }
}
$(function () {
    personal.init();
    problems.init();
})
